﻿<m:EntityListBase
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:m="clr-namespace:Signum.Windows"
    x:Class="Signum.Windows.EntityList"
    x:Name="me" 
	Style="{DynamicResource toolTip}"
	MinHeight="32">
	<m:EntityListBase.Resources>
		<ResourceDictionary>
			<ResourceDictionary.MergedDictionaries>
				<ResourceDictionary Source="../Resources.xaml"/>
			</ResourceDictionary.MergedDictionaries>
			<Style x:Key="AllBlueListBoxItem" TargetType="{x:Type ListBoxItem}">
				<Setter Property="Background" Value="Transparent"/>
				<Setter Property="HorizontalContentAlignment" Value="{Binding Path=HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ListBox}}}"/>
				<Setter Property="VerticalContentAlignment" Value="{Binding Path=VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ListBox}}}"/>
				<Setter Property="Padding" Value="2,0,0,0"/>
				<Setter Property="Template">
					<Setter.Value>
						<ControlTemplate TargetType="{x:Type ListBoxItem}">
							<Border SnapsToDevicePixels="true" x:Name="Bd" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}">
								<ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
							</Border>
							<ControlTemplate.Triggers>
								<Trigger Property="IsSelected" Value="true">
									<Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
									<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/>
								</Trigger>
								<MultiTrigger>
									<MultiTrigger.Conditions>
										<Condition Property="IsSelected" Value="true"/>
										<Condition Property="Selector.IsSelectionActive" Value="false"/>
									</MultiTrigger.Conditions>
									<Setter Property="Background" TargetName="Bd" Value="#FF74B9FF"/>
								</MultiTrigger>
								<Trigger Property="IsEnabled" Value="false">
									<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
								</Trigger>
							</ControlTemplate.Triggers>
						</ControlTemplate>
					</Setter.Value>
				</Setter>
			</Style>
		</ResourceDictionary>
	</m:EntityListBase.Resources>

	<Grid>
		<Grid.ColumnDefinitions>
			<ColumnDefinition/>
			<ColumnDefinition Width="Auto"/>
		</Grid.ColumnDefinitions>
		<Border BorderBrush="{DynamicResource BlueBorder}" BorderThickness="1,1,1,1" CornerRadius="2,2,2,2" Padding="0,0,0,0" SnapsToDevicePixels="True">
			<ListBox 
			x:Name="listBox"
			IsSynchronizedWithCurrentItem="True" 
			Background="{DynamicResource BlueBackground}" 
			BorderBrush="{DynamicResource BlueBorder}" BorderThickness="0,0,0,0" 
			SelectionMode="{Binding Path=SelectionMode, ElementName=me, Mode=Default}" 
			SelectedItem="{Binding Path=Entity, ElementName=me, Mode=Default}" 
            ItemsSource="{Binding Path=Entities, ElementName=me, Mode=Default}" 
			ItemTemplate="{Binding Path=EntityTemplate, ElementName=me, Mode=Default}" 
            ItemContainerStyle="{StaticResource AllBlueListBoxItem}"
			HorizontalContentAlignment="Stretch"
            MouseDoubleClick="listBox_MouseDoubleClick"/>
		</Border>
		<StackPanel Orientation="Vertical" HorizontalAlignment="Left" Grid.Column="1">
			<Button Focusable="False" x:Name="btCreate" Click="btCreate_Click" Style="{DynamicResource RoundButton}" Content="{StaticResource Create}" ToolTip="{m:Loc Create}"/>
			<Button Focusable="False" x:Name="btFind" Click="btFind_Click" Style="{DynamicResource RoundButton}" Content="{StaticResource Find}" ToolTip="{m:Loc Find}"/>
			<Button Focusable="False" x:Name="btView" Style="{DynamicResource RoundButton}" Click="btView_Click" Content="{DynamicResource View}" ToolTip="{m:Loc View}"/>
			<Button Focusable="False" x:Name="btRemove" Style="{DynamicResource RoundButton}" Click="btRemove_Click" Content="{DynamicResource Remove}" ToolTip="{m:Loc Remove}"/>
			<Button Focusable="False" x:Name="btUp" Style="{DynamicResource RoundButton}" Click="btUp_Click"  Content="{DynamicResource Up}" ToolTip="{m:Loc MoveUp}"/>
			<Button Focusable="False" x:Name="btDown" Style="{DynamicResource RoundButton}" Click="btDown_Click"  Content="{DynamicResource Down}" ToolTip="{m:Loc MoveDown}"/>
		</StackPanel>
	</Grid>
</m:EntityListBase>
